<template>
  <div class="police-page">
    <div class="sidebar">
      <div class="menu-title">
        <img style="width: 100px;height: 100px;" src="@/assets/imgs/police.png" alt="logo" class="logo">
        天眼警方</div>
      <ul class="menu-list">
        <li @click="handleMenuClick('missing')" :class="{ active: selectedMenu === 'missing' }">
          <i class="el-icon-user"></i>
          失踪人口管理
        </li>
        <li @click="handleMenuClick('video')" :class="{ active: selectedMenu === 'video' }">
          <i class="el-icon-video-camera"></i>
          监控视频上传
        </li>
        <li @click="handleMenuClick('clue')" :class="{ active: selectedMenu === 'clue' }">
          <i class="el-icon-document"></i>
          线索管理
        </li>
      </ul>
    </div>
    <div class="content">
      <router-view></router-view>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useRouter } from 'vue-router'
import { ref, onMounted } from 'vue'

const router = useRouter()
const selectedMenu = ref('missing') // 默认选中菜单项

const handleMenuClick = (path: string) => {
    selectedMenu.value = path // 更新选中菜单项
  router.push(`/policePage/${path}`)
}
// 页面加载时默认选中第一项
onMounted(() => {
  router.push(`/policePage/${selectedMenu.value}`)
})
</script>

<style scoped>
.police-page {
  display: flex;
  width: 100%;
  height: 100vh;
  background-color: #1e90ff;
}

.sidebar {
  width: 240px;
  background-color: #001529;
  color: white;
  padding: 20px 0;
}

.menu-title {
  display: flex; /* 使用flexbox布局 */
  align-items: center; /* 垂直居中对齐 */
  font-size: 20px;
  text-align: center;
  padding: 20px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-list li {
  padding: 15px 20px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.menu-list li.active {
  background-color: #106abf; /* 高亮显示选中项 */
  color: white; /* 选中项文字颜色 */
}

.menu-list li:hover {
  background-color: #106abf;
}

.menu-list i {
  margin-right: 10px;
}

.content {
  flex: 1;
  padding: 20px;
  background-color: white;
  margin: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
</style>
